import VueRouter from "vue-router";
import Vue from "vue";

Vue.use(VueRouter)

const router = new VueRouter({
    mode:'history',
    routes:[
        {
            path:'/',
            redirect:'/home'
        },
        {
            path:'/Home',
            component:()=>import('@/pages/Home'),
            redirect:'/home/movie',
            children:[
                {
                    path:'movie',
                    name:'Movie',
                    component:()=>import('@/pages/Home/Movie')
                },
                {
                    path:'music',
                    component:()=>import('@/pages/Home/Music'),
                    children:[
                        {
                            path:'musicDetail',
                            name:'MusicDetail',
                            component:()=>import('@/pages/Home/Music/MusicDetail'),
                            //1.props是一个布尔类型的值
                            // props:true,

                            //2.props是一个对象
                            // props:{
                            //     name:'张杰',
                            //     age:24
                            // },

                            //3.props是一个函数,函数接受一个参数为$route对象
                            props:(route)=>({...route.query}),

                            //meta传参
                            meta:{
                                title:'电影主题'
                            }
                        }
                    ]
                }
            ]
        },
        {
            path:'/Login',
            component:()=>import('@/pages/Login')
        }
    ]
})

export default router